#include <stdio.h>

#include "SocketUtils.h"
#include "Log.h"

int	main(int argc, char **argv) {
    char buffer[100] = {0};

    TcpSocket socket = {0};

    // if (createTcpSocketWithHostPort(&socket, "127.0.0.1", 8080)) {
    if (createTcpSocket(&socket)) {
        setSocketConnectAddress(&socket.address, AF_INET, "127.0.0.1", 8080);
        if (socketConnect(&socket, &socket.address, sizeof(socket.address))) {
            WARNING_LOG("连接成功");
            int len = tcpSocketRead(&socket, buffer, 100);
            INFO_LOG("receiver: len: %d: %s", len, buffer);
            len = tcpSocketWrite(&socket, buffer, sizeof(buffer));
            INFO_LOG("send: len: %d: %s", len, buffer);
        }
    } else {
        WARNING_LOG("连接失败");
    }
    return 0;
}